"use strict";
cc._RF.push(module, 'e8284ugFrpAY5N3Xw8GXY5M', 'Level_goldMiner_shopItem');
// scripts/levelBundles/level_goldMiner/other/Level_goldMiner_shopItem.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var MainRoot_1 = require("../../../Game/MainRoot");
var data_control_1 = require("../../../engines/libs/data_control");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var level_goldMiner_shopItem = /** @class */ (function (_super) {
    __extends(level_goldMiner_shopItem, _super);
    function level_goldMiner_shopItem() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.icon = null;
        _this.lbName = null;
        _this.adNode = null;
        _this.moneyNode = null;
        _this.soldOutNode = null;
        _this.lbDesc = null;
        _this.lightNode = null;
        _this.data = null;
        _this.buyFlag = false;
        _this.moneyNum = 0;
        _this.level = null;
        return _this;
    }
    level_goldMiner_shopItem.prototype.bindData = function (data, level) {
        this.data = data;
        this.level = level;
        this.adNode.active = false;
        this.moneyNode.active = false;
        var ad_flag = this.data["ad_flag"];
        this.lightNode.active = false;
        if (ad_flag == "1") {
            this.adNode.active = true;
            this.lightNode.active = true;
            this.lightAni();
        }
        else {
            this.moneyNode.active = true;
            var minMoney = Number(this.data["prop_min_price"]);
            var maxMoney = Number(this.data["prop_max_price"]);
            this.moneyNum = Math.floor(data_control_1.default.getRandNumberOfArrayTwo([minMoney, maxMoney]));
        }
        this.loadIcon();
    };
    level_goldMiner_shopItem.prototype.lightAni = function () {
        var _this = this;
        var tween = cc.tween(this.lightNode).to(4, { angle: 360 }).call(function () {
            _this.lightNode.angle = 0;
        });
        cc.tween(this.lightNode).repeatForever(tween).start();
    };
    level_goldMiner_shopItem.prototype.loadIcon = function () {
        var _this = this;
        this.lbName.string = this.data["prop_name"];
        this.lbDesc.string = this.data["prop_desc"];
        var lbMoney = this.moneyNode.getChildByName("lbMoney").getComponent(cc.Label);
        lbMoney.string = this.moneyNum.toString();
        MainRoot_1.default.LevelSystem.getOneTypeBundle(this.level.getLevelInfo().levelType).load("itemIcon/" + this.data["sp_path"], cc.SpriteFrame, function (err, spr) {
            if (err) {
                console.log(err, "加载icon失败");
                return;
            }
            _this.icon.spriteFrame = spr;
        });
    };
    level_goldMiner_shopItem.prototype.onBuy = function () {
        this.buyFlag = true;
        this.adNode.active = false;
        this.moneyNode.active = false;
        this.soldOutNode.active = true;
    };
    __decorate([
        property({ type: cc.Sprite, tooltip: "icon节点" })
    ], level_goldMiner_shopItem.prototype, "icon", void 0);
    __decorate([
        property({ type: cc.Label, tooltip: "名字文本" })
    ], level_goldMiner_shopItem.prototype, "lbName", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "广告节点" })
    ], level_goldMiner_shopItem.prototype, "adNode", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "钱节点" })
    ], level_goldMiner_shopItem.prototype, "moneyNode", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "售罄节点" })
    ], level_goldMiner_shopItem.prototype, "soldOutNode", void 0);
    __decorate([
        property({ type: cc.Label, tooltip: "描述文本" })
    ], level_goldMiner_shopItem.prototype, "lbDesc", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "光圈节点" })
    ], level_goldMiner_shopItem.prototype, "lightNode", void 0);
    level_goldMiner_shopItem = __decorate([
        ccclass
    ], level_goldMiner_shopItem);
    return level_goldMiner_shopItem;
}(cc.Component));
exports.default = level_goldMiner_shopItem;

cc._RF.pop();